from common.Base import open_op_browser, Base

welcome_url = "http://localhost:8080/ecshop/user.php"
path = r"C:\Users\鲁\AppData\Roaming\Mozilla\Firefox\Profiles\e9vu01pj.default-release-1"


class WelcomePage(Base):
    welcome_title = ("class name", "f5")  # 定位欢迎页的 小标题
    user_integral = ("css selector", "div.f_l")  # 定位会员消费积分
    grade_integral = ("class name", "boxCenterList")  # 定位会员等级积分

    def welcome_text(self):  # 欢迎页的 小标题文本
        return self.get_element_text(self.welcome_title)

    def user_integral_text(self):  # 获取会员消费积分文本
        return self.get_element_text(self.user_integral)

    def grade_integral_text(self):  # 获取会员等级积分文本
        return self.get_element_text(self.grade_integral)


if __name__ == '__main__':
    driver = open_op_browser(path)
    lp = WelcomePage(driver)
    lp.open_url(welcome_url)
    # print(lp.welcome_text())
    print(lp.grade_integral_text())
